$(document).ready(function(){ 
 
	var t_col = ['北京','天津','河北','山西','内蒙古','辽宁','吉林','黑龙江','上海','江苏','浙江','安徽','福建','江西','山东','河南','湖北','湖南','重庆','四川','贵州','云南','西藏','陕西','甘肃','青海','宁夏','新疆','广东','广西','海南','台湾','香港','澳门'];
	$('#col01').val(new Yd_list().init(t_col).getStringLines());

	t_col = ['177','42','102','81','47','67','82','66','24','92','114','109','116','91','119','137','116','114','91','125','62','83','9','80','56','10','18','67','123','59','14','0','0','0'];
	$('#col02').val(new Yd_list().init(t_col).getStringLines());

	$('#chart_button').click(function(){
		
		var col01 = yd_text_input_col('#col01');
		var col02 = yd_text_input_col('#col02');

		var t_keys = ['name', 'value'];
		var t_clists = [col01, col02];
		
		var t_yd_mat = new Yd_mat().init(t_clists).bldTranspose();
		var t_lists = t_yd_mat.get();

		var t_yd_frame = new Yd_frame().initKeysLists(t_keys, t_lists);
		var t_dicts = t_yd_frame.getDicts();

		g_var.q_map_region = t_dicts;

		// 20240801 杭州轨迹
		p_url = g_var.g_mapdata + 'hangzhou-tracks.json';
		p_callback = function(data){
			const t_lines = data.map(function (track) {
				return {
					coords: track.map(function (seg, idx) {
						return seg.coord;
					})
				};
			});
			g_var.q_map_lines = t_lines;


			var t_series = [];
			var t_map_name = 'bmap';
			var t_serie1 = new YdMap(t_map_name).data(g_var.q_map_region).name('区域').get();
			
			var f_symbol_size = function(p_value) {
				var t_max = $('#max_value').val() - 0,
					t_min = $('#min_value').val() - 0,
					t_size = $('#scatter_size').val() - 0;

				var maxSize2Pin = 100,
					minSize2Pin = 30;
				var a = (maxSize2Pin - minSize2Pin) / (t_max - t_min);
				var b = minSize2Pin + a * (p_value - t_min);
				var c = b * t_size;
				return c;
			}

			t_series = t_series.concat(t_serie1);

			var t_max = $('#max_value').val() - 0,
				t_min = $('#min_value').val() - 0; 

			
			var t_serie2 = new YdLines().lineStyle('purple', 0.6, 1).data(g_var.q_map_lines).get();

			t_series = [t_serie2];

			var t_bmap = new YdBMap(t_map_name).center([120.13066322374, 30.240018034923]).zoom(14).get();
			var t_option = new YdOption().bgColor('transparent')
				.att('bmap', t_bmap).series(t_series).get();
			
			// var t_option = {
			// 	backgroundColor: 'transparent',
			// 	bmap: {
			// 	center: [120.13066322374, 30.240018034923],
			// 	zoom: 14,
			// 	roam: true
			// 	},
			// 	series: [
			// 	{
			// 		type: 'lines',
			// 		coordinateSystem: 'bmap',
			// 		data: g_var.q_map_lines, 
			// 		// data: t_series,
			// 		polyline: true,
			// 		lineStyle: {
			// 			color: 'purple',
			// 			opacity: 0.6,
			// 			width: 1
			// 		}
			// 	}
			// 	]
			// };


			new YdChart().init('map_div').option(t_option).get();

		};
		$.get(p_url,p_callback);
		

		

		
	});/*click function*/
		
});
